

# 查看命令使用文档
# ----------------------------------------------------------------------------
# https://sqoop.apache.org/docs/1.4.5/SqoopUserGuide.html#_literal_sqoop_import_literal
# ----------------------------------------------------------------------------
#
[bwie@node101 ~]$ sqoop import --help
# 数据同步命令，先启动HDFS服务：hdp.sh hdfs ，再启动YARN服务：hdp.sh yarn


# ==================================================================================
# todo 1. 广告信息表
# ==================================================================================
sqoop import \
--connect jdbc:mysql://node101:3306/jtp_ads \
--username root \
--password 123456 \
--query 'SELECT id, product_id, material_id, group_id, ad_name, materail_url FROM jtp_ads.ads WHERE $CONDITIONS AND 1 = 1;' \
--delete-target-dir \
--target-dir 'hdfs://node101:8020/warehouse/ads_basic/ads/2024-10-01' \
--as-textfile \
--fields-terminated-by '\001' \
--num-mappers 1 \
--null-string '\\N' \
--null-non-string '\\N'


# ==================================================================================
# todo 2. 广告平台信息表
# ==================================================================================
sqoop import \
--connect jdbc:mysql://node101:3306/jtp_ads \
--username root \
--password 123456 \
--query 'SELECT id, ad_id, platform_id, create_time, cancel_time FROM jtp_ads.ads_platform WHERE $CONDITIONS AND 1 = 1;' \
--delete-target-dir \
--target-dir 'hdfs://node101:8020/warehouse/ads_basic/ads_platform/2024-10-01' \
--as-textfile \
--fields-terminated-by '\001' \
--num-mappers 1 \
--null-string '\\N' \
--null-non-string '\\N'



# ==================================================================================
# todo 3. 平台信息表
# ==================================================================================
sqoop import \
--connect jdbc:mysql://node101:3306/jtp_ads \
--username root \
--password 123456 \
--query 'SELECT id, platform, platform_alias_zh FROM jtp_ads.platform_info WHERE $CONDITIONS AND 1 = 1;' \
--delete-target-dir \
--target-dir 'hdfs://node101:8020/warehouse/ads_basic/platform_info/2024-10-01' \
--as-textfile \
--fields-terminated-by '\001' \
--num-mappers 1 \
--null-string '\\N' \
--null-non-string '\\N'




# ==================================================================================
# todo 4. 产品信息表
# ==================================================================================
sqoop import \
--connect jdbc:mysql://node101:3306/jtp_ads \
--username root \
--password 123456 \
--query 'SELECT id, name, price FROM jtp_ads.product WHERE $CONDITIONS AND 1 = 1;' \
--delete-target-dir \
--target-dir 'hdfs://node101:8020/warehouse/ads_basic/product/2024-10-01' \
--as-textfile \
--fields-terminated-by '\001' \
--num-mappers 1 \
--null-string '\\N' \
--null-non-string '\\N'


